#ifndef SIZEHANDLE_H
#define SIZEHANDLE_H

#include <QObject>
#include <QPoint>

const int g_penWidth = 2;

class QPainter;

class SizeHandlePrivate
{
public:
    SizeHandlePrivate(int point);
    int m_dir;
    QPoint m_center;
    int m_sideLength;
};

class SizeHandle : public QObject
{
    Q_OBJECT
public:
    enum { Handle_None = 0 , LeftTop , Top, RightTop, Right, RightBottom, Bottom, LeftBottom, Left };

    explicit SizeHandle(int point = Handle_None, QObject *parent = nullptr);
    SizeHandle(const SizeHandle &sh, QObject *parent = nullptr);
    SizeHandle & operator=(const SizeHandle &sh);
    int direction() const;
    void setDirection(int dir);
    void setCenter(const QPoint &center);
    QPoint center() const;
    void setSideLength(int len);
    int sideLength() const;
    void paint(QPainter *painter);
    bool containsPoint(const QPoint &pt) const;
    QRectF rect() const;
signals:

private:
    SizeHandlePrivate *d_ptr;
};

#endif // SIZEHANDLE_H
